package com.david.course_design.shopping_center.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultBody {
    private Integer code;
    private String msg;
    private Object restData;

    public static ResultBody success(Object o) {
        ResultBody resultBody = new ResultBody();
        resultBody.setCode(200);
        resultBody.setMsg("请求成功");
        resultBody.setRestData(o);
        return resultBody;
    }

    public static ResultBody error(Object o) {
        ResultBody resultBody = new ResultBody();
        resultBody.setCode(400);
        resultBody.setMsg("请求失败");
        resultBody.setRestData(o);
        return resultBody;
    }

    public static ResultBody error(Object o, String msg) {
        ResultBody resultBody = new ResultBody();
        resultBody.setCode(400);
        resultBody.setMsg(msg);
        resultBody.setRestData(o);
        return resultBody;
    }

}
